package cn.zcx;

import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

/**
 * description:
 * author:zcx
 * lenovo
 * 时间：2022.02.07.14.16
 */
public class T16 {
    Object lock = new Object();

    public static void main(String[] args) {
        var ex = new T16();

    }



    void start(){
        String t = Thread.currentThread().getName();
        System.out.printf("%s线程启动%n", t);
        synchronized (lock){
            lock.notifyAll();
            try {
                lock.wait();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
    void add() {
        String t = Thread.currentThread().getName();
        System.out.printf("%s线程启动%n", t);
        synchronized (lock) {
            try {
                //lock.
                lock.wait();
                Thread.sleep(2000);
                TimeUnit.SECONDS.sleep(2);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

        }
        System.out.printf("");
    }
}
